const bcrypt = require('bcryptjs')

const {
    sequelize
} = require('../../core/db')


const {
    Sequelize,
    Model
} = require('sequelize')

const {Booking} = require("../models/booking");

class Equipment extends Model {


    static async selectAllWithRange(id) {

        const booking = await Booking.findAll({
            attributes: ['start', 'end'],
            where: {
                mid: mid,
                status: status
            }
        });
    }



    static async deleteMoudle(id) {
        const equipment = await Equipment.destroy({
            where: {
                id
            }
        })
        return equipment
    }

    static async updateMoudle(id, status, code, name, type, original, btime, cumulative, pic) {
        const equipment = await Equipment.update({
            status, code, name, type, original, btime, cumulative, pic
        }, {
            where: {
                id
            }
        });
        return equipment
    }
}


Equipment.init({
    id: {
        type: Sequelize.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    status: Sequelize.STRING,
    code: Sequelize.STRING,
    name: Sequelize.STRING,
    type: Sequelize.STRING,
    original: Sequelize.STRING,
    btime: Sequelize.DATE, // 添加 created_at 字段
    cumulative: Sequelize.STRING,
    pic: Sequelize.STRING,
    createdAt: Sequelize.DATE, // 添加 created_at 字段的对应属性
    updatedAt: Sequelize.DATE, // 添加 updated_at 字段的对应属性
}, {
    sequelize,
    tableName: 'equipment'
})


module.exports = {
    Equipment
}


